﻿--生成员工编码
create proc [dbo].[proc_Employee_Number]
as
	--正式员工编码
	declare @enumber nvarchar(20)
	--最后一个员工编码
	declare @endEnumber nvarchar(20)
	--是否是第一条记录
	declare @introw int
	set @introw = (select count(id) from employee)
	if(@introw = 0)
		begin
			set @enumber = Convert(varchar(4),year(getdate()),120) + '0001'
		end
	else
		begin
			set @endEnumber = (select top 1 enumber from employee order by id desc)
			set @enumber = (@endEnumber + 1)
		end
	--返回员工编号
	select @enumber as enumber
